<?php
// print_r($_POST);
// exit;
include_once("/var/www/html/new/com.inc.php");
// include("/var/www/html/new/conf/yd.le.je");
// include_once("/var/www/html/new/d/common/yd.le.je");
include("shoppingcart.class.php");
if(!($fid=$_SESSION['memberID'])){
    exit('{"code":104}');
}
// $GLOBALS['le']=new yd_go_sql();
// $GLOBALS['le']->connect(); 
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true")); 
$sc=new shoppingcart($s,$_SESSION['memberID']);
$adult = $_POST['joiner'][1];//成人数量
$stu   = $_POST['joiner'][2];//学生数量
$eld   = $_POST['joiner'][3];//老人数量
$mantype = array('1'=>'家庭','2'=>'公司团队','3'=>'学生团队','4'=>'情侣','5'=>'亲子','6'=>'老年人','7'=>'年轻人');
$type= $mantype[$_POST['mantype']];
$email = array('mantype'=>$type,'canjiarenshu'=>array('成人'=>$adult,'学生'=>$stu,'老人'=>$eld));
setcookie('email', serialize($email),time()+3600, '/');
// print_r($_COOKIE);
// exit;
$starttime=$_POST['traleldate'];
   //私人订制添加
if(isset($_POST['traleldate'])){ 
    //景区和出行方式
    $heqilai = $_POST['triptype'].','.$_POST['lid'];
    $lid=explode(",",$heqilai);
    foreach($lid as $v){
        $sc->addwhole($v, $starttime,$adult,$stu,$eld);
    }
//酒店
    if(is_array($_POST['hotel'])){
        $sc->addhotel($_POST['hotel']);
    }
    //餐饮    
    if(is_array($_POST['eatmode'])){
        foreach($_POST['eatmode'] as $k =>$v){
            $sc->addG($k,$v,$starttime);
        }
    }
    //出行
}else{
    //单个产品添加
    if(isset($_POST['p_type'])){
        // $p_type = $_POST['p_type'];            
        // $lid = $_POST['lid'];
        // $tid = $_POST['tid'];
        // $num = $_POST['count'];
        $sc->addone($_POST['p_type'],$_POST['lid'],$_POST['tid'],$_POST['count'],$_POST['aid']);            
    }else{
        exit('{"code":104}');
    }
}
$fid = $_SESSION['memberID'];
$sql = "select count(*) as numlok from uu_shoppingcart where fid=$fid and access='{$_SERVER['HTTP_HOST']}'";
$GLOBALS['le']->query($sql);
$GLOBALS['le']->fetch_assoc();
$numlok = $GLOBALS['le']->f('numlok');
print_r(json_encode(array('code'=>'200','cartCount'=>$numlok)));